using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Batch.Dto;
using JTZY.Model.Batch;
using JTZY.Service.Batch.IBatchService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-03-05
namespace JTZY.Admin.WebApi.Controllers.Batch
{
    /// <summary>
    /// 批量发货物码
    /// </summary>
    [Verify]
    [Route("batch/Batchshipdetail")]
    public class BatchshipdetailController : BaseController
    {
        /// <summary>
        /// 批量发货物码接口
        /// </summary>
        private readonly IBatchshipdetailService _BatchshipdetailService;

        public BatchshipdetailController(IBatchshipdetailService BatchshipdetailService)
        {
            _BatchshipdetailService = BatchshipdetailService;
        }

        /// <summary>
        /// 查询批量发货物码列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "batchshipdetail:list")]
        public IActionResult QueryBatchshipdetail([FromQuery] BatchshipdetailQueryDto parm)
        {
            var response = _BatchshipdetailService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询批量发货物码详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "batchshipdetail:query")]
        public IActionResult GetBatchshipdetail(int Id)
        {
            var response = _BatchshipdetailService.GetInfo(Id);
            
            var info = response.Adapt<BatchshipdetailDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加批量发货物码
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "batchshipdetail:add")]
        [Log(Title = "批量发货物码", BusinessType = BusinessType.INSERT)]
        public IActionResult AddBatchshipdetail([FromBody] BatchshipdetailDto parm)
        {
            var modal = parm.Adapt<Batchshipdetail>().ToCreate(HttpContext);

            var response = _BatchshipdetailService.AddBatchshipdetail(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新批量发货物码
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "batchshipdetail:edit")]
        [Log(Title = "批量发货物码", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateBatchshipdetail([FromBody] BatchshipdetailDto parm)
        {
            var modal = parm.Adapt<Batchshipdetail>().ToUpdate(HttpContext);
            var response = _BatchshipdetailService.UpdateBatchshipdetail(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除批量发货物码
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "batchshipdetail:delete")]
        [Log(Title = "批量发货物码", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteBatchshipdetail([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_BatchshipdetailService.Delete(idArr));
        }

    }
}